package com.yto.cn.map;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dongxing
 **/
public class HashMapTest {

    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("周瑜", "周瑜");
        map.put("孙权", "孙权");
        map.put("诸葛亮", "诸葛亮");
        map.put("刘备", "刘备");
        map.put("曹操", "曹操");

        for (String key : map.keySet()) {
            //hashCode的值
            int hashCode = key.hashCode();
            //索引下标
            int index = hashCode % 8;
            System.out.println(String.format("%s的hashcode为%s,下标为：%s",key,hashCode,index));



        }


    }
}
